<template>
  <div class="mod-role">
    <el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
      <el-form-item>
        <el-input v-model="dataForm.key" placeholder="订单号" clearable></el-input>
      </el-form-item>
      <el-form-item>
        <el-button @click="getDataList()">查询</el-button>
      </el-form-item>
    </el-form>
    <el-table
      :data="dataList"
      border
      v-loading="dataListLoading"
      @selection-change="selectionChangeHandle"
      style="width: 100%;"
    >
      <el-table-column type="selection" header-align="center" align="center" width="50"></el-table-column>
      <el-table-column
        prop="orderNo"
        header-align="center"
        align="center"
        width="80"
        label="订单号"
        show-overflow-tooltip
      ></el-table-column>
      <el-table-column prop="routeTitle" header-align="center" align="center" label="路线"></el-table-column>
      <el-table-column prop="nickname" header-align="center" align="center" label="会员名称"></el-table-column>
      <el-table-column prop="totalFee" header-align="center" align="center" label="金额"></el-table-column>
      <el-table-column prop="payType" header-align="center" align="center" label="支付类型"></el-table-column>
      <el-table-column
        prop="gmtCreate"
        header-align="center"
        align="center"
        width="180"
        label="创建时间"
      ></el-table-column>
    </el-table>
    <el-pagination
      @size-change="sizeChangeHandle"
      @current-change="currentChangeHandle"
      :current-page="pageIndex"
      :page-sizes="[10, 20, 50, 100]"
      :page-size="pageSize"
      :total="totalPage"
      layout="total, sizes, prev, pager, next, jumper"
    ></el-pagination>
    <demand-add-or-update
      v-if="addOrUpdateVisible"
      ref="addOrUpdate"
      @refreshDataList="getDataList"
    ></demand-add-or-update>
  </div>
</template>
<script>
export default {
  data() {
    return {
      order: {
        
      },
      dataForm: {
        key: "",
      },
      dataList: [],
      pageIndex: 1,
      pageSize: 10,
      totalPage: 0,
      dataListLoading: false,
      dataListSelections: [],
      addOrUpdateVisible: false,
    };
  },
  activated() {
    this.getDataList();
  },
  methods: {
    //获取数据列表
    getDataList() {
      //this.dataListLoading = true;
      this.$http({
        url: this.$http.adornUrl(
          `/order/getOrderList/${this.pageIndex}/${this.pageSize}`
        ),
        method: "post",
        params: this.$http.adornParams({
          name: this.dataForm.key,
        }),
      }).then(({ data }) => {
        console.log("获取订单列表", data);
        if (data && data.code === 20000) {
          this.dataList = data.data.list;
          this.totalPage = data.data.totalPage;
        } else {
          this.dataList = [];
          this.totalPage = 0;
        }
      });
    },
    // 每页数
    sizeChangeHandle(val) {
      this.pageSize = val;
      this.pageIndex = 1;
      this.getDataList();
    },
    // 当前页
    currentChangeHandle(val) {
      this.pageIndex = val;
      this.getDataList();
    },
    // 多选
    selectionChangeHandle(val) {
      this.dataListSelections = val;
    },
  },
};
</script>

<style>
.el-dropdown-link {
  cursor: pointer;
  color: #409eff;
}
.el-icon-arrow-down {
  font-size: 12px;
}
</style>